<template>
  <div>
      <table align="center" width="600px">
          <tr>
              <td>id</td>
              <td>礼品名</td>
              <td>所需积分</td>
              <td>所剩数量</td>
              <td>操作</td>
          </tr>
          <tr v-for="i in plist" :key="i.id">
              <td>{{i.id}}</td>
              <td>{{i.name}}</td>
              <td>{{i.sum1}}</td>
              <td>
                  {{i.num}}
              </td>
              <td>
                  <van-button @click="putfun(i.id)">兑换</van-button>
              </td>
          </tr>
      </table>
  </div>
</template>

<script>
export default {
    name:'present',
    data(){
        return{
            plist:[],
            uid:localStorage.getItem('uid')
        }
    },
    methods:{
        getp(){
            this.axios.get('/present').then(res=>{
                console.log(res);
                this.plist = res.data.list
            })
        },
        putfun(id){
            this.axios.post('/present',{'pid':id,'uid':this.uid}).then(res=>{
                console.log(res);
            })
        }
    },
    mounted(){
        this.getp()
    }
}
</script>

<style>

</style>